<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <a-form-item label="品牌名称">
              <a-input-number style="width:100%" placeholder="请输入医院名称" v-model="queryParam.name" ></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons" >
              <a-button type="primary" @click="searchQuery" icon="search" >查询</a-button >
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px" >重置</a-button >
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="crudCreate()" type="primary" icon="plus">新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table 
        ref="table" 
        size="middle" 
        bordered 
        rowKey="id" 
        :scroll="{ x: 1300 }" 
        :columns="columns" 
        :dataSource="tableData" 
        :pagination="ipagination" 
        :loading="loading" 
        @change="handleTableChange" >
        <!--操作-->
        <span slot="action" slot-scope="text, record" >
          <a-popconfirm title="确认失效?" ok-text="确定" cancel-text="取消" @confirm="crudDelete(record.id)">
            <a-button type="danger" icon="delete"></a-button>
          </a-popconfirm>
        </span>
        <!--图片预览块-->
        <span slot="imgPath" slot-scope="text, record">
          <img :src="record.avatar" width="80px" height="80px" />
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <GoodsBrandModal ref="updateForm" @closeModal="closeModal" />
  </a-card>
</template>

<script>
import GoodsBrandModal from './modules/goodsBrandModal'
import ApiTree from "@/api/goods/goodsBrand";
import { Slime, crud } from "@/mixins/slime";
import { evaFiltersMixin } from "@/mixins/evaMixin";

export default {
  name: "goodsBrand",
  mixins: [Slime, evaFiltersMixin],
  components: {
    GoodsBrandModal,
  },
  data() {
    return {
      tableData: [],
      columns: [
        {
          title: "品牌id",
          align: "center",
          dataIndex: "id",
        },
        {
          title: "名称",
          align: "center",
          dataIndex: "name",
        },
        {
          title: "创建时间",
          align: "center",
          dataIndex: "createTime",
        },
        {
          title: "是否启用",
          align: "center",
          dataIndex: "status",
          customRender: function (status) {
            if (status == 1) {
              return "启用"
            } else {
              return "关闭"
            }
          },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
    };
  },
  created() {
    this.loadData();
  },
  methods: {
    // 加载表格数据
    loadData(arg) {
      crud(ApiTree);
      this.loadDataPack(arg).then((res) => {
        let tableData = [];
        if (res.result) {
          tableData = res.result.records;
        }
        this.tableData = tableData;
      });
    },
  },
};
</script>
<style scoped>
</style>